package action;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.web.struts.ActionSupport;

import service.HelloDao;

public class SayHelloAction extends ActionSupport {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			ServletRequest request, ServletResponse response) throws Exception {
		ApplicationContext context = getWebApplicationContext();
		String name = request.getParameter("name");
		HelloDao sh = (HelloDao) context.getBean("sayHello");
		String result = sh.sayHello(name);
		request.setAttribute("msg", result);
		return mapping.findForward("success");
	}
}
